var jwt = require("jsonwebtoken");
var secret = "ljljljljasdfa";
function checkToken(req, res, next) {
  console.log(req.headers);
  jwt.verify(req.headers.token, secret, function (err, data) {
    if (!err) {
      // res.send({
      //   code: 1,
      //   msg: "token合法",
      // });
      next();
    } else {
      res.send({
        code: 0,
        msg: "非法token，请登录",
      });
    }
  });
}
module.exports = {
  checkToken,
};
